<?php

namespace App\Http\Controllers\Api\lak;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Agent;
use App\Utils\Logic\lak\EsMultiple;
use App\Common\Responses;
class DrokerController extends Controller
{
    /*
     * 经纪人列表
     * lak
     * */
    public function DrokerList(Request $request){
        $keyword = $request->all();
        $page = $request->get('page')?:1;
        $size = $request->get('size')?:10;
        $from = ($page-1)*$size;
        //es多条件搜索
        if (!empty($keyword)) {

            if (isset($keyword['name'])&&!empty($keyword['name'])) $query[] = ['match'=>['name'=>$keyword['name']]];
            if (isset($keyword['phone'])&&!empty($keyword['phone'])) $query[] = ['match'=>['phone'=>$keyword['phone']]];
            if (isset($keyword['status'])&&!empty($keyword['status'])) $query[] = ['match'=>['status'=>$keyword['status']]];

            $field='name';
            $data = EsMultiple::EsMultipleSearch($query,$field,$from,$size);

            $data =  json_decode(json_encode($data),true);
            return Responses::success($data,200,'成功');
        }
        $room = Agent::lookBroder();
        return Responses::success($room,200,'列表获取成功');
    }



}
